#!/bin/sh
################################################################################
# security
#
# The script configures the security.
################################################################################
. /etc/rc.d/functions

start() {

    /bin/touch /var/lib/init/security.inprogress

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/security] Starting..."
    mm_message_output info "configuring security ..."

    /bin/sed -e "s%^minimyth::1000:1000:%minimyth::${MM_SECURITY_USER_MINIMYTH_UID}:${MM_SECURITY_USER_MINIMYTH_GID}:%" \
             -i /etc/passwd
    /bin/sed -e "s%^minimyth:x:1000:%minimyth:x:${MM_SECURITY_USER_MINIMYTH_GID}:%" \
             -i /etc/group

    if [ -e /etc/pki/tls/certs/ca-bundle.crt ] ; then
        # Set permissions.
        /bin/chmod 0644 /etc/pki/tls/certs/ca-bundle.crt
        # Link to the default name.
        /bin/rm -f /etc/pki/tls/cert.pem
        /bin/ln -fs certs/ca-bundle.crt /etc/pki/tls/cert.pem
        # Add KSSL's bundle.
        if [ -w /usr/kde/share/apps/kssl/ca-bundle.crt ] ; then
            /bin/cat /etc/pki/tls/certs/ca-bundle.crt >> /usr/kde/share/apps/kssl/ca-bundle.crt
        fi
    fi

    if [ -e /etc/cifs/credentials_cifs ] ; then
        # Set permissions.
        /bin/chmod 0600 /etc/cifs/credentials_cifs
    fi

    /usr/bin/logger -s -t minimyth -p "local0.info" "[init.d/security] Started with return code=0..."

    /bin/rm -f /var/lib/init/security.inprogress

    mm_message_output info "starting multiple daemons in background ..."

    return 0
}

stop() {
    return 0
}

case $1 in
    start) start ;;
    stop)  stop  ;;
esac

exit 0
